var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_OpenBox_UIBindings = require("AA_UI_OpenBox_UIBindings");
var UIView = require("AA_UIView");
var AudioManager = require("AA_AudioManager");
var BundleConfig = require("AA_BundleConfig");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_OpenBox = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    t.boxType = 0;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype._show = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
    this.clickCallBack = e.clickCallBack;
    this.boxType = e.boxType;
    this.auto_ui.txt_countLabel.string = e.boxCount + "";
    this.auto_ui.dbAnim_box1.node.active = 0 == e.boxType;
    this.auto_ui.dbAnim_box2.node.active = 1 == e.boxType;
    if (1 == e.boxType) {
      this.auto_ui.txt_titleLabel.string = "精致礼盒";
      this.auto_ui.dbAnim_box2.playAnimation("daiji_1", 0);
    } else {
      this.auto_ui.txt_titleLabel.string = "普通礼盒";
      this.auto_ui.dbAnim_box1.playAnimation("daiji_1", 0);
    }
    this.StartTween();
  };
  _creator.prototype._clickListener = function (e) {
    switch (e) {
      case this.auto_ui.btn_openBtn:
        this.onClick();
    }
  };
  _creator.prototype.StartTween = function () {
    var e = this;
    this.auto_ui.btn_openBtn.node.active = false;
    this.auto_ui.node_boxNode.stopAllActions();
    this.auto_ui.node_titileNode.stopAllActions();
    this.auto_ui.node_titileNode.scaleX = 0;
    this.auto_ui.node_lightNode.stopAllActions();
    this.auto_ui.node_lightNode.scale = 0;
    this.auto_ui.node_boxNode.y = 1e3;
    this.auto_ui.node_boxNode.runAction(cc.sequence(cc.moveTo(.35, 0, 0), cc.scaleTo(.05, 1, .8), cc.scaleTo(.05, 1, 1), cc.callFunc(function () {
      e.auto_ui.node_lightNode.runAction(cc.sequence(cc.scaleTo(.25, 1.1, 1.1), cc.scaleTo(.05, 1, 1), cc.callFunc(function () {
        e.auto_ui.node_lightNode.runAction(cc.repeatForever(cc.rotateBy(3, 360)));
        e.auto_ui.btn_openBtn.node.active = true;
      })));
      e.auto_ui.node_titileNode.runAction(cc.scaleTo(.25, 1, 1));
    })));
  };
  _creator.prototype.onClick = function () {
    var e = this;
    this.auto_ui.btn_openBtn.node.active = false;
    AudioManager.AudioMgr.playEffect("home/sound/openBox", false, BundleConfig.BundleNames.Home);
    if (0 == this.boxType) {
      this.auto_ui.dbAnim_box1.playAnimation("kai", 0);
    } else {
      this.auto_ui.dbAnim_box2.playAnimation("kai", 0);
    }
    this.scheduleOnce(function () {
      e.auto_ui.node_lightNode.stopAllActions();
      e.clickCallBack && e.clickCallBack();
      e._close();
    }, 1.1);
  };
  __decorate([_property(UI_OpenBox_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_OpenBox;